package com.ibeeking.found.common.config.feign;

import com.ibeeking.found.common.config.feign.fallback.GlobalClientFallbackFactory;
import com.ibeeking.found.common.entity.AreaQuery;
import com.ibeeking.found.common.entity.ShortUrlQueryFeign;
import com.ibeeking.found.common.entity.VariableQuery;
import com.ibeeking.found.common.entity.open.OpenAuthQuery;
import com.ibeeking.found.common.entity.open.OpenConfigDTO;
import com.ibeeking.found.common.entity.open.OpenConfigQuery;
import com.ibeeking.found.common.entity.open.OpenAuthDTO;
import com.ibeeking.found.common.entity.IndustryFrontendDTO;
import com.ibeeking.nematos.utils.result.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * @Author ibeeking
 */
@FeignClient(name = "gmc-global-g-server", contextId = "globalClient", path = "/g", fallbackFactory = GlobalClientFallbackFactory.class, decode404 = true)
public interface GlobalClient {

    /**
     * 查询行业的前端可见性
     *
     * @param industry
     * @param frontend
     * @return
     */
    @PostMapping("/datasource/feign/v1/queryIndustryFrontend/{industry}/{frontend}")
    ResponseResult<List<com.ibeeking.found.common.entity.IndustryFrontendDTO>> queryIndustryFrontend(@PathVariable("industry") String industry, @PathVariable("frontend") String frontend);
    /**
     * 查询平台全局变量
     *
     * @return
     */
    @PostMapping(value = "/variable/feign/v1/queryGlobalVariable")
    ResponseResult<com.ibeeking.found.common.entity.GlobalVariableDTO> queryGlobalVariable(@RequestBody VariableQuery query);

    /**
     * 查询租户全局变量
     *
     * @return
     */
    @PostMapping(value = "/variable/feign/v1/queryTenantVariable")
    ResponseResult<com.ibeeking.found.common.entity.TenantVariableDTO> queryTenantVariable(@RequestBody VariableQuery query);
    /**
     * 查询数据源配置
     *
     * @param configId
     * @return
     */
    @PostMapping("/datasource/feign/v1/queryDatasourceConfig/{configId}")
    ResponseResult<com.ibeeking.found.common.entity.DatasourceConfigDTO> queryDatasourceConfig(@PathVariable("configId") Long configId);
    /**
     * 查询租户数据源
     *
     * @param tenantId
     * @return
     */
    @PostMapping("/datasource/feign/v1/queryTenantDatasource/{tenantId}")
    ResponseResult<com.ibeeking.found.common.entity.DatasourceConfigDTO> queryTenantDatasource(@PathVariable("tenantId") Integer tenantId);
    /**
     * 查询模板库
     * @return
     */
    @PostMapping(value = "/datasource/feign/v1/listTemplateByIndustry/{industry}")
    ResponseResult<List<com.ibeeking.found.common.entity.DatabaseTemplateDTO>> listTemplateByIndustry(@PathVariable("industry") String industry);

    /**
     * 查询所有有效租户id
     *
     * @return
     */
    @PostMapping(value = "/tenant/feign/v1/queryTenantIds")
    ResponseResult<List<Integer>> queryTenantIds();

    /**
     * 查询租户信息通过租户编码
     *
     * @param code
     * @return
     */
    @PostMapping("/tenant/feign/v1/queryTenantByCode/{code}")
    ResponseResult<com.ibeeking.found.common.entity.TenantDTO> queryTenantByCode(@PathVariable("code") String code);
    /**
     * 查询租户信息通过租户编码
     *
     * @param id
     * @return
     */
    @PostMapping("/tenant/feign/v1/queryTenantById/{id}")
    ResponseResult<com.ibeeking.found.common.entity.TenantDTO> queryTenantById(@PathVariable("id") Integer id);
    /**
     * 查询租户信息通过租户编码
     *
     * @param id
     * @return
     */
    @PostMapping("/tenant/feign/v1/queryTenantIndustryById/{id}")
    ResponseResult<String> queryTenantIndustryById(@PathVariable("id") Integer id);
    /**
     * 查询有效的微信第三方平台配置信息
     * @param query
     * @return
     */
    @PostMapping(value = "/open/feign/v1/queryOpenConfigList")
    ResponseResult<List<OpenConfigDTO>> queryOpenConfigList(@RequestBody OpenConfigQuery query);
    /**
     * 查询第三方平台公众号配置信息
     * @param query
     * @return
     */
    @PostMapping(value = "/open/feign/v1/queryOpenConfigOne")
    ResponseResult<OpenConfigDTO> queryOpenConfigOne(@RequestBody OpenConfigQuery query);
    // 查询第三方平台开放平台授权信息

    /**
     * 取得所有租户的开放平台授权权限列表
     * @return
     */
    @PostMapping(value = "/openAuth/feign/v1/queryOpenAuthList")
    ResponseResult<List<OpenAuthDTO>> queryOpenAuthList(@RequestBody OpenAuthQuery query);
    /**
     * 取得租户的开放平台授权列表
     * @param query
     * @return
     */
    @PostMapping(value = "/openAuth/feign/v1/queryOpenAuthOne")
    ResponseResult<OpenAuthDTO> queryOpenAuthOne(@RequestBody OpenAuthQuery query);
    /**
     * 根据用户ids查询用户基本信息
     *
     * @return
     */
    @PostMapping(value = "/tenant/feign/v1/queryByUserIds")
    ResponseResult<List<com.ibeeking.found.common.entity.OperatorDTO>> queryByUserIds(@RequestBody List<Long> userIds);
    /**
     * 查询定时任务模板
     *
     * @return
     */
    @PostMapping(value = "/timeTask/feign/v1/queryTimeTaskByHandler/{industry}/{handler}")
    ResponseResult<com.ibeeking.found.common.entity.TimeTaskDTO> queryTimeTaskByHandler(@PathVariable("industry") String industry, @PathVariable("handler") String handler);

    /* 全局字典 */

    /**
     * 批量获取字典列表
     *
     * @param dictTypes
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictByTypes")
    ResponseResult<List<com.ibeeking.found.common.entity.DictDTO>> queryDictByTypes(@RequestBody String[] dictTypes);

    /**
     * 获取字典列表
     *
     * @param dictType
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictByType/{dictType}")
    ResponseResult<List<com.ibeeking.found.common.entity.DictDTO>> queryDictByType(@PathVariable("dictType") String dictType);

    /**
     * 批量获取字典lable
     *
     * @param paramMap
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictLables")
    ResponseResult<List<com.ibeeking.found.common.entity.DictDTO>> queryDictLables(@RequestBody Map<String, String> paramMap);

    /**
     * 获取字典lable
     *
     * @param dictType
     * @param dictValue
     * @return
     */
    @PostMapping(value = "/dictValue/feign/v1/queryDictLable/{dictType}/{dictValue}")
    ResponseResult<com.ibeeking.found.common.entity.DictDTO> queryDictLable(@PathVariable("dictType") String dictType, @PathVariable("dictValue") String dictValue);

    /* 中国地理区域 */

    /**
     * 根据编码查询名称
     *
     * @param code 地区编码
     * @return code
     */
    @PostMapping(value = "/area/feign/v1/queryName/{code}")
    ResponseResult<com.ibeeking.found.common.entity.AreaDTO> queryName(@PathVariable("code") String code);

    /**
     * 根据编码查询名称
     *
     * @param codes 编码列表
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryNames")
    ResponseResult<List<com.ibeeking.found.common.entity.AreaDTO>> queryNames(@RequestBody List<String> codes);

    /**
     * 根据名称查询编码等信息
     *
     * @param areaQuery 名称列表
     * @return 返回
     */
    @PostMapping(value = "/area/feign/v1/queryArea")
    ResponseResult<List<com.ibeeking.found.common.entity.AreaDTO>> queryArea(@RequestBody AreaQuery areaQuery);

    /**
     * 查询短链接页面映射列表
     * @param query
     * @return
     */
    @PostMapping(value = "/shortUrl/feign/v1/queryShortUrlList")
    ResponseResult<List<com.ibeeking.found.common.entity.ShortUrlDTO>> queryShortUrlList(@RequestBody ShortUrlQueryFeign query);

    /**
     * 查询短链接页面映射
     * @param query
     * @return
     */
    @PostMapping(value = "/shortUrl/feign/v1/queryShortUrlOne")
    ResponseResult<com.ibeeking.found.common.entity.ShortUrlDTO> queryShortUrlOne(@RequestBody ShortUrlQueryFeign query);
}
